import mongoose, { Document } from 'mongoose';

import { CloudFileSchemaInterface } from '../../interfaces/db/cloud-file-schema.interface';
import { commonFields } from './common-fileds';

const Schema = mongoose.Schema;

const CloudFileSchema = new Schema({
  key: { type: String, required: true },
  hash: { type: String, required: true },
  fsize: { type: Number, required: true },
  bucket: { type: String, required: true },
  ...commonFields
});

const CloudFileModel = mongoose.model<CloudFileSchemaInterface & Document>('cloudFile', CloudFileSchema);

export default CloudFileModel;
